<template>
	<view>
		<myhead left="1" txt="邀请好友"></myhead>
		<qrcode class="code" :value="codeUrl" v-if="codeUrl"></qrcode>
		<view class="txt" v-if="codeUrl">
			邀请地址：<span>{{codeUrl}}</span>
		</view v-if="codeUrl">
		<view class="btn" @tap="copyBtn" v-if="codeUrl">复制链接</view>
	</view>
</template>

<script>
	import qrcode from "../../components/qrcode/index";
	const http = require('../../utils/http.js');
	export default {
		data() {
			return {
				codeUrl:''
			}
		},
		onShow() {
			uni.showLoading({
			    title: '加载中'
			});
			http.get('/api/app/getAppVersion').then(res => {
				//console.log(res)
				if (res.code == 200 && res.result) {
					this.codeUrl=res.result.downUrl
				}
				uni.hideLoading();
			})
		},
		components: {
		  qrcode
		},
		methods: {
			copyBtn: function () {
			  var that = this;
			  uni.setClipboardData({
			    //准备复制的数据
			    data: that.codeUrl,
			    success: function (res) {
			      uni.showToast({
			        title: '复制成功'
			      });
			    }
			  });
			},
		}
	}
</script>

<style>
	page{
		background: #F5F8FF;
	}
	.code{
		margin: 20vw auto;
		background: #FFFFFF;
		padding: 6vw;
		border-radius: 2vw;
	}
	.txt{
		width: 100%;
		text-align: center;
		font-size: 3.8vw;
		color: #999999;
		margin: 0 auto;
	}
	.txt span{
		color: #24EBA9;
	}
	.btn{
		width: 84%;
		padding: 4vw 0;
		font-size: 3.5vw;
		border-radius: 1.8vw;
		background-image: linear-gradient(45deg, #24EBA9, #10C7B2);
		color: #FFFFFF;
		text-align: center;
		margin: 0 auto;
		margin-top: 10vw;
	}
</style>
